package com.cwits.wifi.ui.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.os.Handler;
import android.os.Message;
import android.text.Layout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.FloatMath;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import com.cwits.wifi.R;
import com.cwits.wifi.util.Dbug;
import com.jieli.lib.stream.beans.VideoInfo;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;

/**
 * Created by ZhangHua on 16-03-01.
 */
public class TLView extends View {
    private final String tag = getClass().getSimpleName();
    private float mDistanceForTwoFinger;
    private int mCurrentGrade = 1;
    private long mCurrentScale = 0;
    private long mCurrentTime = 0L;
    private long mMinTime = 0L;
    private boolean mCanZoomOrDrag = true;
    private boolean mLock = false;

    private boolean mIsExistSdcard = true;

    /**
     * 拖动时间轴的监听
     */
    public interface OnValueChangeListener {
        /**
         * value不再变化，终点
         *
         * @param calendar 刻度盘上当前时间
         */
        void onValueChangeEnd(Calendar calendar);

        /**
         * 时间轴操作的时候，中间时刻的时间
         *
         * @param dateStr 日期
         * @param timeStr 时间
         */
        void onMiddleTime(String dateStr,String timeStr);

        /**
         * 拖动到最右边时刻的监听
         */
        void onArrivedRight();

        /**
         * 拖动到最左边时刻的监听
         */
        void onArrivedLeft();

        /**
         * 手指触摸的时候监听
         */
        void onTouchDown();

        /**
         * 手指抬起的监听
         */
        void onTouchUp();

        void onCannotMoving();

        /**
         * 时间轴锁定的监听
         * @param exist_Sdcard
         * @param s
         * @param info
         */
        void onLock(boolean exist_Sdcard,boolean s,String info);
    }

    private static final long SEC_MILLIS = 1000;//millisecond
    private static final long MIN_MILLIS = 60 * SEC_MILLIS;
    private static final long HOUR_MILLIS = 60 * MIN_MILLIS;
    private static final long DAY_MILLIS = HOUR_MILLIS * 24;

    private int mFontWidth = 3;
    private int mFontHeight = 5;
    private int mLineInter1 = 12;
    private int mLineInter2 = 31;
    private int mInterCount = 6;

    private TextPaint textPaint, blacktext30;
    private TextPaint dateAndTimePaint;
    private Paint middlePaint;

    private Paint blackline, redline, magentaline, redtext20, blacktext20, blacktext15, eventPaint,mPaint;
    private List<VideoInfo> calstuff = null;

    /**
     * 设置时间轴上的内容
     * @param c
     */
    public void SetCalStuff(List<VideoInfo> c) {
        calstuff = c;
        if(calstuff != null)
        {
            for(int i = 0;i < calstuff.size();i++)
            {
                if(i == 0)
                {
                    mMinTime = calstuff.get(i).getStartTime().getTimeInMillis();
                }else
                {
                    if(calstuff.get(i).getStartTime().getTimeInMillis() < mMinTime)
                        mMinTime = calstuff.get(i).getStartTime().getTimeInMillis();
                }
            }
            setExistSdcard(true);
        }
        this.invalidate();
    }

    /**
     * width of view in pixels
     */
    private int width;
    /**
     * Height of view in pixels
     */
    private int mHeight;
    /**
     * left and right limit of the ruler in view, in milliseconds
     */
    private long left, right;
    /**
     * how many fingers are being used? 0, 1, 2
     */
    int fingers;
    /**
     * holds pointer id of #1/#2 fingers
     */
    int finger1id, finger2id;
    /**
     * holds x/y in pixels of #1/#2 fingers from last frame
     */
    float finger1x, finger1y, finger2x, finger2y;

    /**
     * width of the view in milliseconds, cached value of (right-left)
     */
    float span;//跨度
    /**
     * how many pixels does each millisecond correspond to?
     */
    float pixels_per_milli;
    /**
     * length in pixels of time units, at current zoom scale
     */
    float sec_pixels, min_pixels, hour_pixels, day_pixels;

    /**
     * reusable calendar class object for rounding time to nearest applicable unit in onDraw
     */
    private Calendar acalendar;

    private OnValueChangeListener mOnValueChangeListener;/*时间轴的监听listener*/

    /**
     * 是否正在移动
     */
    private boolean isMove = false;

    public TLView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    public TLView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public TLView(Context context) {
        super(context);
        init();
    }

    /**
     * 初始化
     */
    private void init() {
        mCurrentGrade = 8;
        mCanZoomOrDrag = true;
        mPaint = new Paint();
        textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        textPaint.setColor(Color.WHITE);
        textPaint.setTextSize(30);

        dateAndTimePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        dateAndTimePaint.setColor(Color.WHITE);
        dateAndTimePaint.setTextSize(30);

        eventPaint = new Paint();
        eventPaint.setStrokeWidth(1f);
        eventPaint.setAntiAlias(true);
        eventPaint.setColor(Color.RED);
        eventPaint.setAlpha(1);

        middlePaint = new Paint();
        middlePaint.setStrokeWidth(1f);
        eventPaint.setAntiAlias(true);
        middlePaint.setColor(Color.WHITE);

        blackline = new Paint();
        blackline.setColor(Color.WHITE);
        blackline.setStrokeWidth(1f);
        blackline.setAntiAlias(true);
        blackline.setStyle(Style.STROKE);

        blacktext20 = new Paint();
        blacktext20.setColor(Color.WHITE);
        blacktext20.setStrokeWidth(1f);
        blacktext20.setAntiAlias(true);
        blacktext20.setStyle(Style.FILL);
        blacktext20.setTextSize(20);

        blacktext15 = new Paint();
        blacktext15.setColor(Color.WHITE);
        blacktext15.setStrokeWidth(1f);
        blacktext15.setAntiAlias(true);
        blacktext15.setStyle(Style.FILL);
        blacktext15.setTextSize(15);

        blacktext30 = new TextPaint();
        blacktext30.setColor(Color.WHITE);
        blacktext30.setStrokeWidth(1f);
        blacktext30.setAntiAlias(true);
//        blacktext30.setStyle(Style.STROKE);
        blacktext30.setTextSize(20);

        redline = new Paint();
        redline.setColor(Color.RED);
        redline.setStrokeWidth(2f);
        redline.setAntiAlias(true);
        redline.setStyle(Style.STROKE);

        redtext20 = new Paint();
        redtext20.setColor(Color.RED);
        redtext20.setStrokeWidth(1f);
        redtext20.setAntiAlias(true);
        redtext20.setStyle(Style.FILL);
        redtext20.setTextSize(20);

        magentaline = new Paint();
        magentaline.setColor(Color.MAGENTA);
        magentaline.setStrokeWidth(1f);
        magentaline.setAntiAlias(true);
        magentaline.setStyle(Style.STROKE);

        acalendar = new GregorianCalendar();

        // start the view off somewhere, +/- some time around now
//        left = System.currentTimeMillis() - 1 * DAY_MILLIS;
//        right = System.currentTimeMillis() + 2 * DAY_MILLIS;
//        left = System.currentTimeMillis() - DAY_MILLIS;
//        right = System.currentTimeMillis() + DAY_MILLIS;
        left = System.currentTimeMillis() - 2 * HOUR_MILLIS;
        right = System.currentTimeMillis() + 2 * HOUR_MILLIS;
//        left = System.currentTimeMillis() - MIN_MILLIS;
//        right = System.currentTimeMillis() + MIN_MILLIS;
        span = right - left;
//        Log.d(tag, "left=" + left + ", right=" + right + ", span=" + span);
    }

    /**
     * 初始化大小
     * @param changed
     * @param left
     * @param top
     * @param right
     * @param bottom
     */
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        width = getWidth();
        mHeight = getHeight();
        mCurrentScale = getScaleByGrade(mCurrentGrade,width);
        super.onLayout(changed, left, top, right, bottom);
    }

    private static final int MSG_GET_THUMBNAIL = 0x100;
    private static final int MSG_SET_TIME = MSG_GET_THUMBNAIL + 2;
    static final SimpleDateFormat yyyy_MMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    private final Handler handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_GET_THUMBNAIL:
                    if (mOnValueChangeListener != null) {
//                        long time = left + (right - left) / 2;
                        long time = (long) msg.obj;
                        acalendar.setTimeInMillis(time);
                        Log.i(tag, "MSG_GET_THUMBNAIL Format time=" + yyyy_MMddHHmmss.format(time));
                        mOnValueChangeListener.onValueChangeEnd(acalendar);
                    }
                    break;
                case MSG_SET_TIME:

                    break;
            }
            return false;
        }
    });

    public void skipTo(long milliseconds) {
        long middle = left + (right-left)/2;
        long move;

        move = milliseconds - middle;
        if (move > 0) {
            left += move;
            right += move;
            handler.removeMessages(MSG_GET_THUMBNAIL);
            handler.sendEmptyMessageDelayed(MSG_GET_THUMBNAIL, 300);
        }
        invalidate();
    }

    public void setCanZoomOrDrag(boolean is_zoomordrag)
    {
        mCanZoomOrDrag = is_zoomordrag;
    }

    /**
     * 时间轴加锁与解锁
     * @param is_lock
     */
    public void setLock(boolean is_lock)
    {
        mLock = is_lock;
    }

    /**
     * 获取时间轴加解锁状态
     * @return
     */
    public boolean getLock(){
        return mLock;
    }

    /**
     * 设置是否存在sdcard
     * @param statue
     */
    public void setExistSdcard(boolean statue){
        mIsExistSdcard = statue;
    }

    /**
     * 设置中间时刻时间
     * @param offsetMilliseconds
     */
    public void setTimeOffset (long offsetMilliseconds) {
        if (isMove) {
            Dbug.e(tag, "Moving..............");
            return;
        }

        if (offsetMilliseconds == 0) {
            Dbug.e(tag, "offsetMilliseconds = 0");
            return;
        }
        long last = left + (right-left)/2;
        long move = offsetMilliseconds - last;

        if (move >= 1000 || move <= -1000) {
//            Dbug.w(tag, "move =" + move + ", offsetMilliseconds=" + offsetMilliseconds + ", format move= "
//                    + timeFormat.format(move) + ", format offsetMilliseconds=" + timeFormat.format(offsetMilliseconds));
            left += move;
            right += move;
            invalidate();
        }
    }

    /**
     * 获取当前中间时刻时间
     * @return
     */
    public long getCurrentTime(){
        return left + (right-left)/2;
    }

    /**
     * 设置用于接收结果的监听器
     *
     * @param listener 回调的实现
     */
    public void setOnValueChangeListener(OnValueChangeListener listener) {
        mOnValueChangeListener = listener;
    }

    /**
     * 画中间的红色指示线、阴影等。指示线两端简单的用了两个矩形代替
     *
     * @param canvas canvas
     */
    private void drawMiddleLine(Canvas canvas) {
        canvas.save();

        canvas.drawLine(width / 2, 0, width / 2, mHeight, middlePaint);
        canvas.restore();
    }

    /**
     * 画日期时间的文字
     *
     * @param canvas 画布
     */
    private void drawMiddleTimeText(Canvas canvas) {
//        Log.d(tag, "drawMiddleTimeText width=" + width + ", mHeight=" + mHeight);
        // round calendar down to leftmost hour
        acalendar.setTimeInMillis(left + (right-left)/2);

//        String timeStr = date2timeStr(acalendar.getTime());
        String timeStr = timeFormat.format(left + (right - left) / 2);
        String dateStr = date2DateStr(acalendar.getTime());
        if(mOnValueChangeListener != null)
            mOnValueChangeListener.onMiddleTime(dateStr,timeStr);
        //canvas.drawText(timeStr, width / 2 + 10, mHeight / 2 - 70, dateAndTimePaint);
        //drawDateText(canvas);
    }

    private float textWidth = 0;
    /**画日期文本
     * @param canvas 画布
     */
    private void drawDateText(Canvas canvas) {
        String dateStr = date2DateStr(acalendar.getTime());
        textWidth = Layout.getDesiredWidth(dateStr, textPaint);
        canvas.drawText(dateStr, width / 2 - (textWidth + 10), mHeight / 2 - 70, dateAndTimePaint);
    }

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
    public String date2DateStr(Date date) {
        return dateFormat.format(date);
    }

    private static SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
    public String date2timeStr(Date date) {
        return timeFormat.format(date);
    }


    /**
     * 重写绘制时间轴函数
     * @param canvas
     */
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        long next, now;
        mCurrentTime = left + (right  - left)/2;

//        width = getWidth(); // width of view in pixels
        // calculate span/width
        pixels_per_milli = (float) width / span;
        sec_pixels = (float) SEC_MILLIS * pixels_per_milli;
        min_pixels = (float) MIN_MILLIS * pixels_per_milli;
        hour_pixels = (float) HOUR_MILLIS * pixels_per_milli;
        day_pixels = (float) DAY_MILLIS * pixels_per_milli;

        // draw finger circles
/*        if (fingers > 0) {
            canvas.drawCircle(finger1x, finger1y, 60, redline);
            if (fingers > 1) {
                canvas.drawCircle(finger2x, finger2y, 60, magentaline);
            }
        }*/

        // draw ruler
        //canvas.drawLine(0, mHeight, width, mHeight, blackline);

//        canvas.drawText("Minutes in view: " + Integer.toString((int) (width / min_pixels)), 0, getHeight() - 80, redtext20);
//        canvas.drawText("Seconds width: " + Float.toString(sec_pixels), 0, getHeight() - 80, redtext20);
//        canvas.drawText("Minutes width: " + Float.toString(min_pixels), 0, getHeight() - 60, redtext20);
//        canvas.drawText("Hour width: " + Float.toString(hour_pixels), 0, getHeight() - 40, redtext20);
//        canvas.drawText("Day width: " + Float.toString(day_pixels), 0, getHeight() - 20, redtext20);
//        canvas.drawText("day > width: " + Boolean.toString(width < day_pixels), 0, getHeight() - 40, redtext20);

        /**画刻度尺中间的日期和时间文本*/
        drawMiddleTimeText(canvas);
        drawScale(canvas,width,mHeight);


        /*
        // round calendar down to leftmost hour
        acalendar.setTimeInMillis(left);
        // floor the calendar to various time units to find where (in ms) they start
        acalendar.set(Calendar.MILLISECOND, 0); // second start
        acalendar.set(Calendar.SECOND, 0); // minute start
        acalendar.set(Calendar.MINUTE, 0); // hour start

//        Log.w(tag, "date=" + date2DateStr(acalendar.getTime()) + ", time=" + date2timeStr(acalendar.getTime()));
        // draw seconds
        if (sec_pixels > 1f) {
            int theSecondOfMinute = acalendar.get(Calendar.SECOND);
            next = acalendar.getTimeInMillis(); // set to start of leftmost hour
            for (long i = next; i < right; i += SEC_MILLIS) {
                float x = ((float) (i - left) / span * width);
                int second = theSecondOfMinute % 60;
                if (sec_pixels < 5f) {
                    if (second == 0 || second == 30) {
                        canvas.drawLine(x, mHeight - 15, x, mHeight, blackline);
                        canvas.drawText(Integer.toString(second), x, mHeight - 10, blacktext30);
                    }
                } else if (sec_pixels < 10f) {
                    if (second % 15 == 0) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                        canvas.drawText(Integer.toString(second), x, mHeight - 10, blacktext30);
                    }
                } else if (sec_pixels < 20f) {
                    if (second == 10 || second == 20 || second == 40 || second == 50) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                        canvas.drawText(Integer.toString(second), x, mHeight - 10, blacktext30);
                    } else if (second == 0 || second == 30) {
                        canvas.drawLine(x, mHeight - 15, x, mHeight, blackline);
                        canvas.drawText(Integer.toString(second), x, mHeight - 10, blacktext30);
                    }
                } else if (sec_pixels < 25f) {
                    if (second % 5 == 0) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                        canvas.drawText(Integer.toString(second), x, mHeight - 10, blacktext30);
                    }
                } else {
                    if (second % 5 == 0) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                        canvas.drawText(Integer.toString(second), x, mHeight - 10, blacktext30);
                    } else {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                    }
                }
                theSecondOfMinute ++;
            }
        }
        // draw minutes
        if (min_pixels > 6f) {
            int theMinuteOfHour = acalendar.get(Calendar.MINUTE);
            next = acalendar.getTimeInMillis(); // set to start of leftmost hour
            for (long i = next; i < right; i += MIN_MILLIS) {
                float x = ((float) (i - left) / span * width);
                int minute = theMinuteOfHour % 60;
                if (min_pixels < 10f) {
                    if (minute % 15==0) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                        canvas.drawText(Integer.toString(minute), x, mHeight - 10, blacktext30);
                    }
                } else if (min_pixels < 25f) {
                    if (minute % 10 == 0) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                        canvas.drawText(Integer.toString(minute), x, mHeight - 10, blacktext30);
                    }
                } else if (min_pixels < 60) {
                    if (minute % 5 == 0) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                        canvas.drawText(Integer.toString(minute), x, mHeight - 10, blacktext30);
                    } else {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                    }
                }
                theMinuteOfHour ++;
            }
        }
        // draw hours
        if (hour_pixels > 2) {
            int thehourofday = acalendar.get(Calendar.HOUR_OF_DAY);
            next = acalendar.getTimeInMillis(); // set to start of leftmost hour
//            Log.i(tag, "hour_pixels=" + hour_pixels + ",thehourofday=" +thehourofday + ",next=" +next);
            for (long i = next; i < right; i += HOUR_MILLIS) {
                float x = ((float) (i - left) / span * (float) width);
                int h24 = thehourofday % 24;
                int h12 = thehourofday % 12;
                if (h12 == 0) h12 = 12;

                if (hour_pixels < 4) {
                    if (h24 == 12)
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                    if (h12 == 6)
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);

                } else if (hour_pixels < 20) {
                    if (h24 == 12)
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                    else if (h12 == 6)
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                    else if ((h12 == 3) || (h12 == 9))
                        canvas.drawLine(x, mHeight - 5, x, mHeight, blackline);

                } else if (hour_pixels < 60) {
                    if (h24 == 12) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                        drawHourText(canvas, x, mHeight - 10, h24, h12);
                    } else if (h12 == 6) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                        drawHourText(canvas, x, mHeight - 10, h24, h12);
                    } else if ((h12 == 3) || (h12 == 9)) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                    } else
                        canvas.drawLine(x, mHeight - 5, x, mHeight, blackline);

                } else if (hour_pixels < 360) {
                    if (h24 == 12) {
                        canvas.drawLine(x, mHeight - 15, x, mHeight, blackline);
                    } else if (h12 == 6) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                    } else if ((h12 == 3) || (h12 == 9)) {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                    } else {
                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                    }
                    drawHourText(canvas, x, mHeight - 10, h24, h12);
                }

                thehourofday++;
            }
        } // done drawing hours

        // draw months
        // round calendar down to leftmost month
        acalendar.set(Calendar.HOUR_OF_DAY, 0); // day start
        acalendar.set(Calendar.DAY_OF_MONTH, 1); // month start
        next = acalendar.getTimeInMillis(); // set to start of leftmost month
        do {
            // draw each month
            int monthnumber = acalendar.get(Calendar.MONTH);
            int daysthismonth = acalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            String monthnamelong = acalendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault());
            String monthnameshort = acalendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault());
            int daynumber = acalendar.get(Calendar.DAY_OF_WEEK);

            long daymsx = next; // first day starts at start of month
            int x = (int) ((daymsx - left) / span * width); // convert to pixels

            canvas.drawLine(x, mHeight - 40, x, mHeight, blackline);

            ///draw each year
            if (monthnumber == 0) {
//                canvas.drawLine(x, mHeight - 130, x, mHeight - 110, blackline);
                canvas.drawLine(x, mHeight - 80, x, mHeight - 60, blackline);
                String year = Integer.toString(acalendar.get(Calendar.YEAR));
                textWidth = Layout.getDesiredWidth(year, blacktext30);
                int textX = (int) (x - textWidth / 2);
//                canvas.drawText(year, x + 8, mHeight - 167, blacktext30);
                canvas.drawText(year, textX, mHeight - 80, blacktext30);
            }

            // draw month names
            if (day_pixels < 1) {

            } else if (day_pixels < 2) {
                textWidth = Layout.getDesiredWidth(monthnameshort, blacktext30);
                // sideways month name
                //canvas.rotate(-90, x, mHeight);
                //canvas.drawText(monthnameshort, x + 10 , mHeight + 20, blacktext30);
                //canvas.restore();
                if ((monthnumber+1) % 3 == 0) {
                    textWidth = Layout.getDesiredWidth(monthnamelong, blacktext30);
                    // long month name
                    canvas.drawText(monthnamelong, x - textWidth/2, mHeight - 40, blacktext30);
                }
            } else if (day_pixels < 5) {
                textWidth = Layout.getDesiredWidth(monthnameshort, blacktext30);
                // short month name
                canvas.drawText(monthnameshort, x - textWidth/2, mHeight - 40, blacktext30);
            } else {
                textWidth = Layout.getDesiredWidth(monthnamelong, blacktext30);
                // long month name
                canvas.drawText(monthnamelong, x - textWidth/2, mHeight - 40, blacktext30);
            }

            // draw days, weeks
            for (int date = 1; date <= daysthismonth; date++, daynumber++, daymsx += DAY_MILLIS) {
                x = (int) ((daymsx - left) / span * width);

                if (daynumber == 7) daynumber = 0;
                if (day_pixels < 3);

                if (day_pixels < 10) {
                    // really tiny days
//                    if (daynumber == 1)
//                        canvas.drawLine(x, mHeight - 10, x, mHeight, blackline);
                } else if (day_pixels < 40) {
                    // tiny days
                    canvas.drawLine(x, mHeight - 30, x, mHeight, blackline);

                } else if (day_pixels > 170) {
                    // big days
                    canvas.drawLine(x, mHeight - 30, x, mHeight, blackline);
                    canvas.drawText(Integer.toString(date), x + 10, mHeight - 30, blacktext30);

                } else {
                    // sideways days
                    canvas.drawLine(x, mHeight - 30, x, mHeight, blackline);
                    canvas.save();
                    canvas.rotate(-90, x, mHeight);
                    canvas.drawText(Integer.toString(date), x + 10, mHeight + 30, blacktext30);
                    canvas.restore();
                }
            }

            acalendar.add(Calendar.MONTH, 1);
            next = acalendar.getTimeInMillis();
        } while (next < right);
        // done drawing months
        */
        // draw some events maybe
        if (calstuff != null) {
            drawEvents(canvas);
        }
        drawMiddleLine(canvas);
    }

    /**draw some events maybe
     * @param canvas canvas
     */
    private void drawEvents(Canvas canvas) {
//        Dbug.e(tag, "drawEvents==" + calstuff.size());
        for (VideoInfo videoInfo : calstuff) {
            long startTime = videoInfo.getStartTime().getTimeInMillis();
            long endTime = videoInfo.getEndTime().getTimeInMillis();
                /*Log.w(tag, "(startTime > right)==" + (startTime > right)+", endTime < left =" + (endTime < left)
                        + ", start time=" + date2timeStr(e.getStartTime().getTime())
                        + ", end time=" + date2timeStr(e.getEndTime().getTime())
                        + ", start date=" + date2DateStr(e.getStartTime().getTime())
                        + ", end date=" + date2DateStr(e.getEndTime().getTime()));*/
            if ((endTime < left) || (startTime > right)) {
                continue;
            }
            if(videoInfo.getIsLocked())
            {
                //eventPaint.setColor(getResources().getColor(R.color.is_lock_color));
                eventPaint.setARGB(100,255,0,0);
            }else
            {
                //eventPaint.setColor(getResources().getColor(R.color.is_no_lock_color));
                eventPaint.setARGB(100,144,69,30);
            }
//            Dbug.e(tag, "drawEvents date=" + date2DateStr(e.getStartTime().getTime()));
            int x = (int) ((startTime - left) / span * width);
            int x2 = (int) ((endTime - left) / span * width);
            if(x2 - x < 1)
                x2 = x + 1;
            int y = mHeight / 2 - 60;
            float h = 56;
            canvas.drawRect(x, 2, x2, mHeight - 2, eventPaint);
        }
    }

    private void drawHourText(Canvas canvas, float x, float y, int h24, int h12) {
        if (h24 < 12) {
            canvas.drawText(Integer.toString(h12), x, y, blacktext30);
        } else {
            canvas.drawText(Integer.toString(h24), x, y, blacktext30);
        }
    }

    /**
     * 重写触摸时间轴函数
     * @param motionevent
     * @return
     */
    @Override
    public boolean onTouchEvent(MotionEvent motionevent) {
        if(mCanZoomOrDrag == false)
        {
            if(mOnValueChangeListener != null)
                mOnValueChangeListener.onCannotMoving();
            return true;
        }

        if(mLock)
        {
            if(mOnValueChangeListener != null)
                mOnValueChangeListener.onLock(mIsExistSdcard,false,"");
            return true;
        }

        switch (motionevent.getActionMasked()) {
            // First finger down, start panning
            case MotionEvent.ACTION_DOWN:

                if(mOnValueChangeListener != null)
                    mOnValueChangeListener.onTouchDown();
                fingers = 1; // panning mode

                // save id and coords
                finger1id = motionevent.getPointerId(motionevent.getActionIndex());
                finger1x = motionevent.getX();
                finger1y = motionevent.getY();

//                Log.d(tag, "down " + finger1x);
                invalidate(); // redraw
                return true;

            // Second finger down, start scaling
            case MotionEvent.ACTION_POINTER_DOWN:
                if(mOnValueChangeListener != null)
                    mOnValueChangeListener.onTouchDown();

                if (fingers == 2) // if already tracking 2 fingers
                    break; // ignore 3rd finger
                // else fingers == 1
                fingers = 2; // scaling mode

                // save id and coords
                finger2id = motionevent.getPointerId(motionevent.getActionIndex());
                finger2x = motionevent.getX(finger2id);
                finger2y = motionevent.getY(finger2id);
                mDistanceForTwoFinger = distance(motionevent);

                Log.d(tag, "2down " + finger2x);
                invalidate(); // redraw
                return true;

            case MotionEvent.ACTION_MOVE:

                if (fingers == 0) // if not tracking fingers as down
                    return false; // ignore move events

                float new1x,
                        new1y,
                        new2x,
                        new2y; // Hold new positions of two fingers

                // get finger 1 position
                int pointerindex = motionevent.findPointerIndex(finger1id);
                if (pointerindex == -1) // no change
                {
                    new1x = finger1x; // use values from previous frame
                    new1y = finger1y;
                } else
                // changed
                {
                    // get new values
                    new1x = motionevent.getX(pointerindex);
                    new1y = motionevent.getY(pointerindex);
                }

                // get finger 2 position
                pointerindex = motionevent.findPointerIndex(finger2id);
                if (pointerindex == -1) {
                    new2x = finger2x;
                    new2y = finger2y;
                } else {
                    new2x = motionevent.getX(pointerindex);
                    new2y = motionevent.getY(pointerindex);
//                    Log.w(tag, "new2x - finger2x=" + (new2x - finger2x));
                }

                // panning
                if (fingers == 1) {
                    // how far to scroll in milliseconds to match the scroll input in pixels
                    long delta1xinmillis = (long) ((finger1x - new1x) * span / width); // (deltax)*span/width
                    // = delta-x
                    // in
                    // milliseconds
                    // pan the view
                    left += delta1xinmillis;
                    right += delta1xinmillis;
                    if((left + (right - left)/2) > System.currentTimeMillis())
                    {
                        left = System.currentTimeMillis() - (long)(span/2);
                        right = System.currentTimeMillis() + (long)(span/2);
                        if(mOnValueChangeListener != null)
                            mOnValueChangeListener.onArrivedRight();
                    }
                    if(mMinTime != 0&&(left + (right - left)/2) < mMinTime)
                    {
                        left = mMinTime - (long)(span/2);
                        right = mMinTime + (long)(span/2);
                        if(mOnValueChangeListener != null)
                            mOnValueChangeListener.onArrivedLeft();
                    }
                    // save
                    finger1x = new1x;
                    finger1y = new1y;
                    finger2x = new2x;
                    finger2y = new2y;
                }
                // scaling
                else if (fingers == 2) {
                    /**Stop stretch*/
                    if (sec_pixels >= 30f) {
                        float a = Math.abs(finger2x - finger1x);
                        float b = Math.abs(new2x - new1x);
                        int c = (int) (b- a);
                        Log.w(tag,"left=" + left +", right=" + right + ", (b-a)=" +(c));
                        if (c > 0) {
                            return false;
                        }
                    } else if (day_pixels < 0.5f) {
                        float a = Math.abs(finger2x - finger1x);
                        float b = Math.abs(new2x - new1x);
                        int c = (int) (b- a);
                        if (c < 0) {
                            return false;
                        }
                    }
                    // don't scale if fingers too close, or past each other
                    if (Math.abs(new1x - new2x) < 10) return true;
                    if (finger1x > finger2x) if (new1x < new2x) return true;
                    if (finger1x < finger2x) if (new1x > new2x) return true;

                    float distance = distance(motionevent);

                    if(distance > mDistanceForTwoFinger)
                    {
                        //放大
                        Log.i("------","MotionEvent.ACTION_MOVE,--ZOOMOUT--,distance:");
                        if(distance - mDistanceForTwoFinger > 50)
                        {
                            mDistanceForTwoFinger = distance;
                            mCurrentGrade = enLarger(mCurrentGrade);
                            long middle =  left + (right - left)/2;
                            mCurrentScale = getScaleByGrade(mCurrentGrade,width);
                            left = middle - mCurrentScale*width/2;
                            right = middle + mCurrentScale*width/2;
                            span = right - left; // span of milliseconds in view
                        }

                    }else if(distance < mDistanceForTwoFinger)
                    {
                        //缩小
                        Log.i("-------","MotionEvent.ACTION_MOVE,--ZOOMINT--,distance:");
                        if(mDistanceForTwoFinger - distance > 50)
                        {
                            mDistanceForTwoFinger = distance;
                            mCurrentGrade = reduce(mCurrentGrade);
                            long middle =  left + (right - left)/2;
                            mCurrentScale = getScaleByGrade(mCurrentGrade,width);
                            left = middle - mCurrentScale*width/2;
                            right = middle + mCurrentScale*width/2;
                            span = right - left; // span of milliseconds in view
                        }
                    }
                    /*
                    double m = (double) span / (double) width; // m = span/width
                    double y1 = m * finger1x + left; // ms at finger1
                    double y2 = m * finger2x + left; // ms at finger2
                    left = (long) (y1 + (0 - new1x) * (y2 - y1) / (new2x - new1x));
                    right = (long) (y1 + (width - new1x) * (y2 - y1) / (new2x - new1x));
                    span = right - left; // span of milliseconds in view
                    // save
                    finger1x = new1x;
                    finger1y = new1y;
                    finger2x = new2x;
                    finger2y = new2y;
                    */
                }


                isMove = true;
                invalidate(); // redraw with new left,right
                return true;

            case MotionEvent.ACTION_POINTER_UP:
                if(mOnValueChangeListener != null)
                    mOnValueChangeListener.onTouchUp();
                int id = motionevent.getPointerId(motionevent.getActionIndex());

                if (id == finger1id) {
                    // 1st finger went up, make 2nd finger new firstfinger and go back to panning
                    finger1id = finger2id;
                    finger1x = finger2x; // copy coords so view won't jump to other finger
                    finger1y = finger2y;
                    fingers = 1; // panning
                } else if (id == finger2id) {
                    // 2nd finger went up, just go back to panning
                    fingers = 1; // panning
                } else {
                    return false; // ignore 3rd finger ups
                }
                invalidate(); // redraw
                return true;

            case MotionEvent.ACTION_UP:
                if(mOnValueChangeListener != null)
                    mOnValueChangeListener.onTouchUp();
                long time = left + (right - left) / 2;
                acalendar.setTimeInMillis(time);
                Log.i(tag, "ACTION_UP Format time=" + yyyy_MMddHHmmss.format(time));
//                Dbug.d(tag, "MotionEvent.ACTION_UP");
                // last pointer up, no more motionevents
                fingers = 0;
                handler.removeMessages(MSG_GET_THUMBNAIL);
                handler.obtainMessage(MSG_GET_THUMBNAIL, time).sendToTarget();
                invalidate(); // redraw
                isMove = false;
                return true;
        }
        return super.onTouchEvent(motionevent);
    }

    public static float distance(MotionEvent event) {
        float dx = event.getX(1) - event.getX(0);
        float dy = event.getY(1) - event.getY(0);
        return FloatMath.sqrt(dx * dx + dy * dy);
    }

    /**
     * 缩小比例
     * @param current_grade
     * @return
     */
    private int reduce(int current_grade)
    {
        int grade = 1;
        if(current_grade > 1)
        {
            grade = current_grade - 1;
        }else
        {
            grade = current_grade;
        }
        return grade;
    }

    /**
     * 放大比例
     * @param current_grade
     * @return
     */
    private int enLarger(int current_grade)
    {
        int grade = 13;
        if(current_grade < 13)
        {
            grade = current_grade + 1;
        }else
        {
            grade = current_grade;
        }
        return grade;
    }

    /**
     * 通过等级获取刻度尺
     * @param grade
     * @return
     */
    private long getScaleByGrade(int grade,int width)
    {
        long scale = 24;
        //if(mVideoFileInfoList == null ||mVideoFileInfoList.size() == 0)
        //   return (mMaxVideoTime - mMinVideoTime)/(12*width);
        switch(grade)
        {
            case 1:
                //间隔14天
                int s1 = 1000*60*60*24*14;
                scale = (s1/(width/4));
                break;
            case 2:
                //间隔一周
                int s = 1000*60*60*24*7;
                scale = (s/(width/4));
                break;
            case 3:
                //间隔三天
                scale = (1000*60*60*24*4*3 /width);
                break;
            case 4:
                //间隔24h
                scale = (1000*60*60*24*4 /width);
                break;
            case 5:
                //间隔12h
                scale = (1000*60*60*24*2 / width);
                break;
            case 6:
                //间隔6h
                scale = (1000*60*60*12*2 / (width));
                break;
            case 7:
                //间隔3h
                scale = (1000*60*60*6*2 / ( width));

                break;
            case 8:
                //间隔1h
                scale = (1000*60*60*2*2 / (width));
                break;
            case 9:
                //间隔30min
                scale = (1000*60*60*2 / (width));
                break;
            case 10:
                //间隔10min
                scale = (1000*60*20*2 / (width));
                break;
            case 11:
                //间隔5min
                scale = (1000*60*10*2 / (width));
                break;
            case 12:
                //间隔1min
                scale = (1000*60*2*2 / ( width));
                break;
            case 13:
                //间隔30s
                scale = (1000*60*1*2 / ( width));
                break;
        }
        return scale;
    }

    /**
     * 绘制刻度尺
     * @param canvas
     * @param width
     * @param height
     */
    private void drawScale(Canvas canvas,int width,int height)
    {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(mCurrentTime);
        int month = calendar.get(Calendar.MONTH)+1;
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int min = calendar.get(Calendar.MINUTE);
        int sec = calendar.get(Calendar.SECOND);

        mPaint.setColor(Color.WHITE);
        mPaint.setTextSize((int)this.getResources().getDimension(R.dimen.btnTextSize));
        mPaint.setFlags(Paint.ANTI_ALIAS_FLAG); //消除锯齿
        calendar.set(Calendar.HOUR_OF_DAY, hour - 1);
        calendar.set(Calendar.MINUTE,0);
        calendar.set(Calendar.SECOND,0);


        switch(mCurrentGrade)
        {
            case 1:
                //间隔24h
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 2:
                //间隔24h
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 3:
                //间隔24h
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 4:
                //间隔24h
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 5:
                //间隔12h
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 6:
                //间隔6h
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 7:
                //间隔3h
                calendar.set(Calendar.HOUR_OF_DAY, hour - 1);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 8:
                //间隔1h
                calendar.set(Calendar.HOUR_OF_DAY, hour - 1);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 9:
                //间隔30min
                calendar.set(Calendar.HOUR_OF_DAY, hour - 1);
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 10:
                //间隔10min
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 11:
                //间隔5min
                calendar.set(Calendar.MINUTE,0);
                calendar.set(Calendar.SECOND,0);
                break;
            case 12:
                //间隔1min
                calendar.set(Calendar.HOUR_OF_DAY, hour);
                calendar.set(Calendar.MINUTE,min);
                calendar.set(Calendar.SECOND,0);
                break;
            case 13:
                //间隔30s
                calendar.set(Calendar.HOUR_OF_DAY, hour);
                calendar.set(Calendar.MINUTE,min);
                calendar.set(Calendar.SECOND,0);
                break;
        }

        long timescale = calendar.getTimeInMillis();
        int scale = width/2 - (int)((mCurrentTime - timescale)/mCurrentScale);
        drawLineAndText(canvas,scale,calendar,width,height);

    }

    /**
     * 绘制时间刻度
     * @param canvas
     * @param current_width
     * @param calendar
     * @param width
     * @param height
     */
    private void drawLineAndText(Canvas canvas,int current_width,Calendar calendar,int width,int height)
    {
        String text  = "";
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH)+1;
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int min = calendar.get(Calendar.MINUTE);
        switch(mCurrentGrade)
        {
            case 1:
                //间隔两周
                //右边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 24*60*60*1000*i/(mCurrentScale/14);
                    if(current_width + interval > width)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day + i * 14);
                        month_text = String.valueOf(month);
                        if(day + i*14 >31)
                        {
                            day_text = String.valueOf(day + i*14 - 31);
                            if(month == 12)
                            {
                                month_text = "1";
                            }else
                            {
                                month_text = String.valueOf(month + 1);
                            }


                        }
                    }else if(month == 2)
                    {
                        //判断是否是闰年
                        if(year%4 == 0)
                        {
                            day_text = String.valueOf(day + i*14);
                            month_text = String.valueOf(month);
                            if(day + i*14 > 29)
                            {
                                day_text = String.valueOf(day + i*14 - 29);
                                month_text = String.valueOf(month + 1);

                            }
                        }else
                        {
                            day_text = String.valueOf(day + i*14);
                            month_text = String.valueOf(month);
                            if(day + i*14 > 28)
                            {
                                day_text = String.valueOf(day + i*14 - 28);
                                month_text = String.valueOf(month + 1);

                            }
                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day + i*14);
                        month_text = String.valueOf(month);
                        if(day + i*14 >30)
                        {
                            day_text = String.valueOf(day + i*14 - 30);
                            month_text = String.valueOf(month + 1);


                        }

                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    text = month_text + "/" + day_text + "";
                    //mPaint.setColor(Color.WHITE);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (14*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (14*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 24*60*60*1000*i/(mCurrentScale/14);
                    if(current_width - interval < 0)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day - i*14);
                        month_text = String.valueOf(month);
                        if(day - i*14 < 0)
                        {
                            if (month == 8)
                            {
                                day_text = String.valueOf(day - i*14 + 31);
                            }else if(month == 3)
                            {
                                if(year%4 == 0)
                                {
                                    day_text = String.valueOf(day - i*14 + 29);
                                }else
                                {
                                    day_text = String.valueOf(day - i*14 + 28);
                                }

                            }else
                            {
                                day_text = String.valueOf(day - i*14 + 30);
                            }

                            if(month == 1)
                            {
                                month_text = "12";
                            }else
                            {
                                month_text = String.valueOf(month - 1);
                            }


                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day - i*14);
                        month_text = String.valueOf(month);
                        if(day - i*14 < 0)
                        {
                            day_text = String.valueOf(day - i*14 + 31);
                            month_text = String.valueOf(month - 1);

                        }

                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    text = month_text + "/" + day_text + "";
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (14*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (14*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 2:
                //间隔一周
                //右边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 7*24*60*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day + i * 7);
                        month_text = String.valueOf(month);
                        if(day + i*7 >31)
                        {
                            day_text = String.valueOf(day + i*7 - 31);
                            if(month == 12)
                            {
                                month_text = "1";
                            }else
                            {
                                month_text = String.valueOf(month + 1);
                            }


                        }
                    }else if(month == 2)
                    {
                        //判断是否是闰年
                        if(year%4 == 0)
                        {
                            day_text = String.valueOf(day + i*7);
                            month_text = String.valueOf(month);
                            if(day + i*7 > 29)
                            {
                                day_text = String.valueOf(day + i*7 - 29);
                                month_text = String.valueOf(month + 1);

                            }
                        }else
                        {
                            day_text = String.valueOf(day + i*7);
                            month_text = String.valueOf(month);
                            if(day + i*7 > 28)
                            {
                                day_text = String.valueOf(day + i*7 - 28);
                                month_text = String.valueOf(month + 1);

                            }
                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day + i*7);
                        month_text = String.valueOf(month);
                        if(day + i*7 >30)
                        {
                            day_text = String.valueOf(day + i*7 - 30);
                            month_text = String.valueOf(month + 1);


                        }

                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    text = month_text + "/" + day_text + "";
                    //mPaint.setColor(Color.WHITE);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (7*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (7*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 7*24*60*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day - i*7);
                        month_text = String.valueOf(month);
                        if(day - i*7 < 0)
                        {
                            if (month == 8)
                            {
                                day_text = String.valueOf(day - i*7 + 31);
                            }else if(month == 3)
                            {
                                if(year%4 == 0)
                                {
                                    day_text = String.valueOf(day - i*7 + 29);
                                }else
                                {
                                    day_text = String.valueOf(day - i*7 + 28);
                                }

                            }else
                            {
                                day_text = String.valueOf(day - i*7 + 30);
                            }

                            if(month == 1)
                            {
                                month_text = "12";
                            }else
                            {
                                month_text = String.valueOf(month - 1);
                            }


                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day - i*7);
                        month_text = String.valueOf(month);
                        if(day - i*7 < 0)
                        {
                            day_text = String.valueOf(day - i*7 + 31);
                            month_text = String.valueOf(month - 1);

                        }

                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    text = month_text + "/" + day_text + "";
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (7*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (7*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 3:
                //间隔3天
                //右边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 3*24*60*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day + i * 3);
                        month_text = String.valueOf(month);
                        if(day + i*3 >31)
                        {
                            day_text = String.valueOf(day + i*3 - 31);
                            if(month == 12)
                            {
                                month_text = "1";
                            }else
                            {
                                month_text = String.valueOf(month + 1);
                            }


                        }
                    }else if(month == 2)
                    {
                        //判断是否是闰年
                        if(year%4 == 0)
                        {
                            day_text = String.valueOf(day + i*3);
                            month_text = String.valueOf(month);
                            if(day + i*3 > 29)
                            {
                                day_text = String.valueOf(day + i*3 - 29);
                                month_text = String.valueOf(month + 1);

                            }
                        }else
                        {
                            day_text = String.valueOf(day + i*3);
                            month_text = String.valueOf(month);
                            if(day + i*3 > 28)
                            {
                                day_text = String.valueOf(day + i*3 - 28);
                                month_text = String.valueOf(month + 1);

                            }
                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day + i*3);
                        month_text = String.valueOf(month);
                        if(day + i*3 >30)
                        {
                            day_text = String.valueOf(day + i*3 - 30);
                            month_text = String.valueOf(month + 1);


                        }

                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    text = month_text + "/" + day_text + "";
                    //mPaint.setColor(Color.WHITE);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (3*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (3*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 3*24*60*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day - i*3);
                        month_text = String.valueOf(month);
                        if(day - i*3 < 0)
                        {
                            if (month == 8)
                            {
                                day_text = String.valueOf(day - i*3 + 31);
                            }else if(month == 3)
                            {
                                if(year%4 == 0)
                                {
                                    day_text = String.valueOf(day - i*3 + 29);
                                }else
                                {
                                    day_text = String.valueOf(day - i*3 + 28);
                                }

                            }else
                            {
                                day_text = String.valueOf(day - i*3 + 30);
                            }

                            if(month == 1)
                            {
                                month_text = "12";
                            }else
                            {
                                month_text = String.valueOf(month - 1);
                            }


                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day - i*3);
                        month_text = String.valueOf(month);
                        if(day - i*3 < 0)
                        {
                            day_text = String.valueOf(day - i*3 + 31);
                            month_text = String.valueOf(month - 1);

                        }

                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    text = month_text + "/" + day_text + "";
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (3*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (3*24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 4:
                //间隔24h
                //右边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 24*60*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day + i);
                        month_text = String.valueOf(month);
                        if(day + i >31)
                        {
                            day_text = String.valueOf(day + i - 31);
                            if(month == 12)
                            {
                                month_text = "1";
                            }else
                            {
                                month_text = String.valueOf(month + 1);
                            }


                        }
                    }else if(month == 2)
                    {
                        //判断是否是闰年
                        if(year%4 == 0)
                        {
                            day_text = String.valueOf(day + i);
                            month_text = String.valueOf(month);
                            if(day + i > 29)
                            {
                                day_text = String.valueOf(day + i - 29);
                                month_text = String.valueOf(month + 1);

                            }
                        }else
                        {
                            day_text = String.valueOf(day + i);
                            month_text = String.valueOf(month);
                            if(day + i > 28)
                            {
                                day_text = String.valueOf(day + i - 28);
                                month_text = String.valueOf(month + 1);

                            }
                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day + i);
                        month_text = String.valueOf(month);
                        if(day + i >30)
                        {
                            day_text = String.valueOf(day + i - 30);
                            month_text = String.valueOf(month + 1);


                        }

                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    text = month_text + "/" + day_text + "";
                    //mPaint.setColor(Color.WHITE);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 24*60*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day - i);
                        month_text = String.valueOf(month);
                        if(day - i < 0)
                        {
                            if (month == 8)
                            {
                                day_text = String.valueOf(day - i + 31);
                            }else if(month == 3)
                            {
                                if(year%4 == 0)
                                {
                                    day_text = String.valueOf(day - i + 29);
                                }else
                                {
                                    day_text = String.valueOf(day - i + 28);
                                }

                            }else
                            {
                                day_text = String.valueOf(day - i + 30);
                            }

                            if(month == 1)
                            {
                                month_text = "12";
                            }else
                            {
                                month_text = String.valueOf(month - 1);
                            }


                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day - i);
                        month_text = String.valueOf(month);
                        if(day - i < 0)
                        {
                            day_text = String.valueOf(day - i + 31);
                            month_text = String.valueOf(month - 1);

                        }

                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    text = month_text + "/" + day_text + "";
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (24*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 5:
                //间隔12h
                //右边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 12*60*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    int day_interval = i/2;
                    int modes = i%2;
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day + day_interval);
                        month_text = String.valueOf(month);
                        if(day + day_interval >31)
                        {
                            day_text = String.valueOf(day + day_interval - 31);
                            if(month == 12)
                            {
                                month_text = "1";
                            }else
                            {
                                month_text = String.valueOf(month + 1);
                            }
                        }
                    }else if(month == 2)
                    {
                        //判断是否是闰年
                        if(year%4 == 0)
                        {
                            day_text = String.valueOf(day + day_interval);
                            month_text = String.valueOf(month);
                            if(day + day_interval > 29)
                            {
                                day_text = String.valueOf(day + day_interval - 29);
                                month_text = String.valueOf(month + 1);

                            }
                        }else
                        {
                            day_text = String.valueOf(day + day_interval);
                            month_text = String.valueOf(month);
                            if(day + day_interval > 28)
                            {
                                day_text = String.valueOf(day + day_interval - 28);
                                month_text = String.valueOf(month + 1);

                            }
                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day + day_interval);
                        month_text = String.valueOf(month);
                        if(day + day_interval >30)
                        {
                            day_text = String.valueOf(day + day_interval - 30);
                            month_text = String.valueOf(month + 1);


                        }
                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    if(modes == 0)
                    {
                        text = month_text + "/" + day_text + " " + "00:00";
                    }else
                    {
                        text = month_text + "/" + day_text + " " + "12:00";
                    }

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (12*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (12*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 12*60*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    mPaint.setColor(Color.WHITE);
                    String month_text = "";
                    String day_text = "";
                    int day_interval = i/2;
                    int modes = i%2;
                    if(modes == 1)
                        day_interval =day_interval + 1;
                    if(month == 1||month == 3||month == 5||month == 7||month == 8||month == 10||month == 12)
                    {
                        //每个月31天
                        day_text = String.valueOf(day - day_interval);
                        month_text = String.valueOf(month);
                        if(day - day_interval < 0)
                        {
                            if (month == 8)
                            {
                                day_text = String.valueOf(day - day_interval + 31);
                            }else if(month == 3)
                            {
                                if(year%4 == 0)
                                {
                                    day_text = String.valueOf(day - day_interval + 29);
                                }else
                                {
                                    day_text = String.valueOf(day - day_interval + 28);
                                }

                            }else
                            {
                                day_text = String.valueOf(day - day_interval + 30);
                            }

                            if(month == 1)
                            {
                                month_text = "12";
                            }else
                            {
                                month_text = String.valueOf(month - 1);
                            }


                        }
                    }else
                    {
                        //每个月30天
                        day_text = String.valueOf(day - day_interval);
                        month_text = String.valueOf(month);
                        if(day - day_interval < 0)
                        {
                            day_text = String.valueOf(day - day_interval + 31);
                            month_text = String.valueOf(month - 1);


                        }

                    }
                    if(month_text.length() == 1)
                        month_text = "0" + month_text;
                    if(day_text.length() == 1)
                        day_text = "0" + day_text;
                    if(modes == 0)
                    {
                        text = month_text + "/" + day_text + " " + "00:00";
                    }else
                    {
                        text = month_text + "/" + day_text + " " + "12:00";
                    }

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (12*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (12*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 6:
                //间隔6h
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 6*60*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    int hour_target = hour + 6*i;
                    if(hour_target >= 24)
                        hour_target = hour_target - 24;
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    text = hour_text + ":00";

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));

                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (6*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (6*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 6*60*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    int hour_target = hour - 6*i;
                    if(hour_target < 0)
                        hour_target = hour_target + 24;
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    text = hour_text + ":00";

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));

                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (6*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (6*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 7:
                //间隔3h
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 3*60*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    mPaint.setColor(Color.WHITE);
                    int hour_target = hour + 3*i;
                    if(hour_target >= 24)
                        hour_target = hour_target - 24;
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    text = hour_text + ":00";
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (3*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (3*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 3*60*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    int hour_target = hour - 3*i;
                    if(hour_target < 0)
                        hour_target = hour_target + 24;
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    text = hour_text + ":00";

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (3*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (3*60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 8:
                //间隔1h
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 60*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    int hour_target = hour + i;
                    if(hour_target >= 24)
                        hour_target = hour_target - 24;
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    text = hour_text + ":00";

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));

                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 60*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    int hour_target = hour - i;
                    if(hour_target < 0)
                        hour_target = hour_target + 24;
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    text = hour_text + ":00";

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (60*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (60*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 9:
                //间隔30min
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 30*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    int hour_interval = i/2;
                    int modes = i%2;
                    int hour_target = hour + hour_interval;
                    if(hour_target >= 24)
                        hour_target = hour_target - 24;
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    if(modes == 0)
                    {
                        text = hour_text + ":00";
                    }else
                    {
                        text = hour_text + ":30";
                    }
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (30*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (30*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 30*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    int hour_interval = i/2;
                    int modes = i%2;
                    if(modes == 1)
                        hour_interval = hour_interval + 1;
                    int hour_target = hour - hour_interval;
                    if(hour_target < 0)
                        hour_target = hour_target + 24;

                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    if(modes == 0)
                    {
                        text = hour_text + ":00";
                    }else
                    {
                        text = hour_text + ":30";
                    }

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (30*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (30*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 10:
                //间隔10min
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 10*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    int hour_interval = i/6;
                    int modes = i%6;
                    mPaint.setColor(Color.WHITE);
                    int hour_target = hour + hour_interval;
                    if(hour_target >= 24)
                        hour_target = hour_target - 24;
                    int min_target = min;
                    switch(modes)
                    {
                        case 1:
                            min_target = min + 10;
                            break;
                        case 2:
                            min_target = min + 20;
                            break;
                        case 3:
                            min_target = min + 30;
                            break;
                        case 4:
                            min_target = min + 40;
                            break;
                        case 5:
                            min_target = min + 50;
                            break;
                    }
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;

                    if(min_target < 10)
                    {
                        text = hour_text + ":0" + String.valueOf(min_target);
                    }else
                    {
                        text = hour_text + ":" + String.valueOf(min_target);
                    }

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (10*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (10*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 10*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    int hour_interval = i/6;
                    int modes = i%6;
                    int min_target = 00;
                    switch(modes)
                    {
                        case 1:
                            min_target = 50;
                            break;
                        case 2:
                            min_target = 40;
                            break;
                        case 3:
                            min_target = 30;
                            break;
                        case 4:
                            min_target = 20;
                            break;
                        case 5:
                            min_target = 10;
                            break;
                    }

                    if(modes != 0)
                        hour_interval = hour_interval + 1;
                    mPaint.setColor(Color.WHITE);
                    int hour_target = hour - hour_interval;
                    if(hour_target < 0)
                        hour_target = hour_target + 24;

                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    if(min_target < 10)
                    {
                        text = hour_text + ":0" + String.valueOf(min_target);
                    }else
                    {
                        text = hour_text + ":" + String.valueOf(min_target);
                    }


                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (10*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (10*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 11:
                //间隔5min
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 5*60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    int hour_interval = i/12;
                    int modes = i%12;
                    mPaint.setColor(Color.WHITE);
                    int hour_target = hour + hour_interval;
                    if(hour_target >= 24)
                        hour_target = hour_target - 24;
                    int min_target = min;
                    switch(modes)
                    {
                        case 1:
                            min_target = min + 5;
                            break;
                        case 2:
                            min_target = min + 10;
                            break;
                        case 3:
                            min_target = min + 15;
                            break;
                        case 4:
                            min_target = min + 20;
                            break;
                        case 5:
                            min_target = min + 25;
                            break;
                        case 6:
                            min_target = min + 30;
                            break;
                        case 7:
                            min_target = min + 35;
                            break;
                        case 8:
                            min_target = min + 40;
                            break;
                        case 9:
                            min_target = min + 45;
                            break;
                        case 10:
                            min_target = min + 50;
                            break;
                        case 11:
                            min_target = min + 55;
                            break;
                    }

                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    if(min_target < 10)
                    {
                        text = hour_text + ":0" + String.valueOf(min_target);
                    }else
                    {
                        text = hour_text + ":" + String.valueOf(min_target);
                    }
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (5*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (5*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 5*60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    int hour_interval = i/12;
                    int modes = i%12;
                    int min_target = 00;
                    switch(modes)
                    {
                        case 1:
                            min_target = 55;
                            break;
                        case 2:
                            min_target = 50;
                            break;
                        case 3:
                            min_target = 45;
                            break;
                        case 4:
                            min_target = 40;
                            break;
                        case 5:
                            min_target = 35;
                            break;
                        case 6:
                            min_target = 30;
                            break;
                        case 7:
                            min_target = 25;
                            break;
                        case 8:
                            min_target = 20;
                            break;
                        case 9:
                            min_target = 15;
                            break;
                        case 10:
                            min_target = 10;
                            break;
                        case 11:
                            min_target = 05;
                            break;
                    }

                    if(modes != 0)
                        hour_interval = hour_interval + 1;
                    int hour_target = hour - hour_interval;
                    if(hour_target < 0)
                        hour_target = hour_target + 24;

                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    if(min_target < 10)
                    {
                        text = hour_text + ":0" + String.valueOf(min_target);
                    }else
                    {
                        text = hour_text + ":" + String.valueOf(min_target);
                    }

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (5*60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (5*60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 12:
                //间隔1min
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 60*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    int hour_interval = i/60;
                    mPaint.setColor(Color.WHITE);
                    int hour_target = hour + hour_interval;
                    if(hour_target >= 24)
                        hour_target = hour_target - 24;
                    int min_target = min + i;
                    while(min_target >= 60)
                    {
                        min_target = min_target - 60;
                    }

                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    if(min_target < 10)
                    {
                        text = hour_text + ":0" + String.valueOf(min_target);
                    }else
                    {
                        text = hour_text + ":" + String.valueOf(min_target);
                    }
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 60*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    int hour_interval = i/60;
                    //if(min_target == 60)
                    //   min_target = 00;
                    //if(i%60 != 0)
                    //hour_interval = hour_interval + 1;
                    int hour_target = hour - hour_interval;
                    int min_target = min - i;
                    if(min_target < 0){
                        hour_target = hour - 1;
                    }
                    while(min_target < 0){
                        min_target = min_target + 60;
                    }


                    if(hour_target < 0)
                        hour_target = hour_target + 24;


                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    if(min_target < 10)
                    {
                        text = hour_text + ":0" + String.valueOf(min_target);
                    }else
                    {
                        text = hour_text + ":" + String.valueOf(min_target);
                    }

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (60*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (60*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
            case 13:
                //间隔30s
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 30*1000*i/mCurrentScale;
                    if(current_width + interval > width)
                        break;
                    int min_interval = i/2;
                    int min_target = min + min_interval;
                    int hour_target = hour;
                    if(min_target >= 60){
                        min_target = min_target - 60;
                        hour_target = hour_target + 1;
                    }
                    if(hour_target >= 24)
                        hour_target = hour_target - 24;
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    String min_text = String.valueOf(min_target);
                    if(min_text.length() == 1)
                        min_text = "0" + min_text;
                    if(i%2 == 0)
                    {
                        text = hour_text + ":" + min_text + ":" + "00";
                    }else
                    {
                        text = hour_text + ":" + min_text + ":" + "30";
                    }

                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width + interval, mLineInter1, current_width + interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width + interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width + interval + (30*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width + interval + (30*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                //左边绘制
                for(int i = 0;i < 1000;i++)
                {
                    float interval = 30*1000*i/mCurrentScale;
                    if(current_width - interval < 0)
                        break;
                    int min_interval = i/2;
                    int hour_target = hour;
                    int min_target = min - min_interval;
                    if(i%2 == 1)
                        min_target = min_target - 1;
                    if(min_target < 0){
                        min_target = min_target + 60;
                        hour_target = hour_target - 1;
                    }
                    if(hour_target < 0)
                        hour_target = hour_target + 24;
                    String hour_text = String.valueOf(hour_target);
                    if(hour_text.length() == 1)
                        hour_text = "0" + hour_text;
                    String min_text = String.valueOf(min_target);
                    if(min_text.length() == 1)
                        min_text = "0" + min_text;
                    if(i%2 == 0)
                    {
                        text = hour_text + ":" + min_text + ":" + "00";
                    }else
                    {
                        text = hour_text + ":" + min_text + ":" + "30";
                    }


                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    canvas.drawLine(current_width - interval, mLineInter1, current_width - interval, height - mLineInter1, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_font__color));
                    canvas.drawText(text, current_width - interval + mFontWidth, height - mFontHeight, mPaint);
                    mPaint.setColor(getResources().getColor(R.color.is_scale_line__color));
                    for(int j = 0;j < (mInterCount - 1); j++ )
                    {
                        canvas.drawLine(current_width - interval - (30*1000/mCurrentScale)*(j + 1)/mInterCount, mLineInter2, current_width - interval - (30*1000/mCurrentScale)*(j + 1)/mInterCount, height - mLineInter2, mPaint);
                    }

                }
                break;
        }
    }

    /**
     * 查找最近的视频文件
     * @param currenttime
     * @return
     */
    public VideoInfo getNearestVideoInfo(long currenttime,boolean isDownload)
    {
        VideoInfo info = null;
        if(calstuff == null)
            return info;
        long intertime = getInterTime(isDownload);

        long temp = 0;
        for(int i = 0;i < calstuff.size();i++)
        {
            if((calstuff.get(i).getStartTime().getTimeInMillis() - currenttime) > 0
                    &&(calstuff.get(i).getStartTime().getTimeInMillis() - currenttime) < intertime)
            {
                if(temp == 0)
                {
                    temp = calstuff.get(i).getStartTime().getTimeInMillis() - currenttime;
                    info = calstuff.get(i);
                }else
                {
                    if(calstuff.get(i).getStartTime().getTimeInMillis() - currenttime < temp)
                    {
                        temp = calstuff.get(i).getStartTime().getTimeInMillis() - currenttime;
                        info = calstuff.get(i);
                    }
                }
            }
        }
        return info;
    }

    private long getInterTime(boolean isDownload)
    {
        long intertime = 0;
        switch(mCurrentGrade)
        {
            case 1:
                intertime = 1000*60*60*2*14*2;
                break;
            case 2:
                intertime = 1000*60*60*2*7*2;
                break;
            case 3:
                intertime = 1000*60*60*2*3*2;
                break;
            case 4:
                intertime = 1000*60*60*2*2;
                break;
            case 5:
                intertime = 1000*60*60*2;
                break;
            case 6:
                intertime = 1000*60*30*2;
                break;
            case 7:
                intertime = 1000*30*30*2;
                break;
            case 8:
                intertime = 1000*30*10*2;
                break;
            case 9:
                intertime = 1000*30*5*2;
                break;
            case 10:
                intertime = 1000*10*5*2;
                break;
            case 11:
                intertime = 1000*5*5*2;
                break;
            case 12:
                if(isDownload){
                    intertime = 13000;
                }else{
                    intertime = 1000*5*2;
                }
                break;
            case 13:
                if(isDownload){
                    intertime = 13000;
                }else{
                    intertime = 500*5*2;
                }
                break;
        }
        return intertime;
    }
}
